package com.xiaoshuidi.cloud.module.contract.api;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.contract.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.contract.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;

import java.util.List;
import java.util.Map;

@FeignClient(name = ApiConstants.SERVERNAME)
@Tag(name = "RPC 服务 -账单")
public interface ContractRentOrderApi {
    /**
     * 账单信息
     *
     * @param id
     * @return
     */
    @GetMapping("/rpc-api/contract/order/get")
    @Operation(summary = "账单及详情")
    CommonResult<RentOrderExtVO> getById(@RequestParam("id") Long id);

    /**
     * 分页查询账单开票信息
     */
    @PostMapping("/rpc-api/contract/order/getInvoiceList")
    CommonResult<PageResult<OrderInvoicePageRespVO>> getInvoiceList(@RequestBody OrderInvoicePageReqVO reqVO);

    /**
     * 获取企业开票数据
     *
     * @param invoiceId
     * @return
     */
    @PostMapping("/rpc-api/contract/order/detail/list")
    CommonResult<List<ContractInvoiceDetailVO>> getOrderDetailList(@RequestParam("invoiceId") Long invoiceId);

    @PostMapping("/rpc-api/contract/order/detail/list/orderNo")
    CommonResult<List<ContractInvoiceDetailVO>> getOrderDetailListByOrderNo(@RequestParam("invoiceId") Long invoiceId);
    /**
     * 修改账单状态--开票状态
     *
     * @param id
     * @return
     */
    @PostMapping("/rpc-api/contract/order/update/invoiceStatus")
    @Operation(summary = "修改账单状态")
    CommonResult<Boolean> updateOrderInvoiceStatus(@RequestParam("id") Long id);

    /**
     * 校验账单实际支付时间是否超过1年
     *
     * @param invoiceId
     * @return
     */
    @PostMapping("/rpc-api/contract/order/checkOrderTime")
    @Operation(summary = "校验账单实际支付时间是否超过1年")
    CommonResult<String> checkOrderTime(@RequestParam("invoiceId") Long invoiceId);

    /**
     * 修改账单状态--开票状态
     *
     * @param invoiceId
     * @return
     */
    @PostMapping("/rpc-api/contract/order/update/invalidateInvoice")
    @Operation(summary = "作废发票，修改订单状态")
    CommonResult<Boolean> updateOrderByInvalidateInvoice(@RequestParam("invoiceId") Long invoiceId);

    /**
     * 修改账单状态--开票状态
     *
     * @param invoiceId
     * @return
     */
    @PostMapping("/rpc-api/contract/order/update/updateOrderByRushRed")
    @Operation(summary = "红冲发票，修改订单状态")
    CommonResult<Boolean> updateOrderByRushRed(@RequestParam("invoiceId") Long invoiceId,@RequestParam("invoiceStatus") int invoiceStatus);

    /**
     * 修改账单状态--开票后修改账单状态
     *
     * @param invoiceId
     * @return
     */
    @PostMapping("/rpc-api/contract/order/update/orderInvoiceStatus")
    @Operation(summary = "修改账单状态--开票后修改账单状态")
    CommonResult<Boolean> orderInvoiceStatus(@RequestBody List<Long> orderIdList,@RequestParam("invoiceId") Long invoiceId,@RequestParam("invoiceStatus") int invoiceStatus);

    /**
     * 修改账单状态
     *
     * @param id
     * @return
     */
    @PostMapping("/rpc-api/contract/order/update/status")
    @Operation(summary = "修改账单状态")
    CommonResult<Boolean> updateOrderStatus(@RequestParam("id") Long id, @RequestParam("status") String status,
                                            @RequestParam(value =
                                                    "oldStatus", required = false) String oldStatus);

    /**
     * 批量修改企业账单状态为处理中
     *
     * @param batchId 批量付款号
     * @status status
     */
    @PostMapping("/rpc-api/contract/order/updateBatch/status")
    @Operation(summary = "批量修改企业账单状态为处理中")
    CommonResult<Boolean> updateOrderBatchStatus(@RequestParam("batchId") String batchId, @RequestParam("status") String status);

    /**
     * 批量还原修改企业账单状态
     *
     * @param batchId 批量付款号
     * @return
     * @status status
     */
    @PostMapping("/rpc-api/contract/order/rollbackBatch/status")
    @Operation(summary = "批量修改企业账单状态为处理中")
    CommonResult<Boolean> rollbackOrderBatchStatus(@RequestParam("batchId") String batchId);


    /**
     * 获取企业开票数据
     *
     * @param reqVO
     * @return
     */
    @PostMapping("/rpc-api/contract/company/invoiceable/list")
    CommonResult<List<CompanyInvoiceRespVO>> getCompanyInvoiceableOrder(@RequestBody CompanyInvoiceReqVO reqVO);

    /**
     * 设置企业开票记录id
     *
     * @param invoiceRecordId 发票记录id
     * @param feeDetailId     需要更新的账单费用明细id
     * @return
     */
    @PostMapping("/rpc-api/contract/company/invoice/set-record-id")
    CommonResult<Void> setInvoiceRecordId(@RequestParam("invoiceRecordId") Long invoiceRecordId,
                                          @RequestBody List<Long> feeDetailId);

    /**
     * 手抄表 生成账单
     */
    @PostMapping("/rpc-api/contract/create/order")
    CommonResult<Long> createOrder(@RequestBody RentOrderCreateMeterReq req);

    /**
     * 根据工单id获取对应的维修工单账单信息
     */
    @PostMapping("/rpc-api/contract/get-sow-ticket-order")
    CommonResult<List<RentOrderSowTicketVO>> getSowTicketOrder(@RequestParam("sowTicketId") Long sowTicketId);

    /**
     * 根据工单id列表获取对应的维修工单账单信息
     */
    @PostMapping("/rpc-api/contract/get-sow-ticket-order-by-ids")
    CommonResult<Map<Long, List<RentOrderSowTicketVO>>> getSowTicketOrderByIds(@RequestBody GetSowTicketOrderByIdsReq getSowTicketOrderByIdsReq);

    /**
     * 根据账单id,费用类型，费项查询实付的订单金额
     */
    @PostMapping("/rpc-api/contract/get-order-amount-by-fee")
    CommonResult<OrderFeeAmountRespVO> getOrderAmountByFee(@Validated @RequestBody OrderFeeAmountReqVO req);

    /**
     * 账单信息
     *
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/rpc-api/contract/order/payment-list")
    @Operation(summary = "账单及详情")
    CommonResult<List<RentOrderExtVO>> getPaymentRentOrderList(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime);


    /**
     * 账单集合获取账单实际支付信息
     *
     * @param ids
     * @return
     */
    @PostMapping("/rpc-api/contract/order/actual/get-by-ids")
    @Operation(summary = "账单集合获取账单实际支付信息")
    CommonResult<List<RentOrderExtVO>> getActualExpensesByOrderIds(@Valid @RequestBody @NotEmpty(message = "参数不能为空") List<Long> ids);

    /**
     * 根据账单号查询费项信息
     * @return
     */
    @GetMapping("/rpc-api/contract/order/fee-list")
    @Operation(summary = "根据账单号查询费项信息")
    CommonResult<List<OrderFeeDetailVO>> getFeeListByOrderIds(@RequestParam("ids") List<Long> ids);

}
